home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.accessibility.Accessible;
- import com.sun.java.accessibility.AccessibleContext;
- import com.sun.java.accessibility.AccessibleState;
- import com.sun.java.swing.event.ChangeListener;
- import com.sun.java.swing.event.EventListenerList;
- import com.sun.java.swing.plaf.ScrollBarUI;
- import java.awt.Adjustable;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.event.AdjustmentEvent;
- import java.awt.event.AdjustmentListener;
-
- public class JScrollBar extends JComponent implements Adjustable, Accessible {
- private ChangeListener fwdAdjustmentEvents;
- protected BoundedRangeModel model;
- protected int orientation;
- protected int unitIncrement;
- protected int blockIncrement;
- static Class class$java$awt$event$AdjustmentListener;
-
- public JScrollBar() {
- this(1);
- }
-
- public JScrollBar(int orientation) {
- this(orientation, 0, 10, 0, 100);
- }
-
- public JScrollBar(int orientation, int value, int extent, int min, int max) {
- this.fwdAdjustmentEvents = new ModelListener(this);
- this.checkOrientation(orientation);
- this.unitIncrement = 1;
- this.blockIncrement = extent == 0 ? 1 : extent;
- this.orientation = orientation;
- this.model = new DefaultBoundedRangeModel(value, extent, min, max);
- this.model.addChangeListener(this.fwdAdjustmentEvents);
- this.updateUI();
- }
-
- public void addAdjustmentListener(AdjustmentListener l) {
- EventListenerList var10000 = super.listenerList;
- Class var10001 = class$java$awt$event$AdjustmentListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("java.awt.event.AdjustmentListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$java$awt$event$AdjustmentListener = var10001;
- }
-
- var10000.add(var10001, l);
- }
-
- private void checkOrientation(int orientation) {
- switch (orientation) {
- case 0:
- case 1:
- return;
- default:
- throw new IllegalArgumentException("orientation must be one of: VERTICAL, HORIZONTAL");
- }
- }
-
- protected void fireAdjustmentValueChanged(int id, int type, int value) {
- Object[] listeners = super.listenerList.getListenerList();
- AdjustmentEvent e = null;
-
- for(int i = listeners.length - 2; i >= 0; i -= 2) {
- Object var10000 = listeners[i];
- Class var10001 = class$java$awt$event$AdjustmentListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("java.awt.event.AdjustmentListener");
- } catch (ClassNotFoundException var7) {
- throw new NoClassDefFoundError(((Throwable)var7).getMessage());
- }
-
- class$java$awt$event$AdjustmentListener = var10001;
- }
-
- if (var10000 == var10001) {
- if (e == null) {
- e = new AdjustmentEvent(this, id, type, value);
- }
-
- ((AdjustmentListener)listeners[i + 1]).adjustmentValueChanged(e);
- }
- }
-
- }
-
- public AccessibleContext getAccessibleContext() {
- if (super.accessibleContext == null) {
- super.accessibleContext = new AccessibleJScrollBar(this);
- }
-
- return super.accessibleContext;
- }
-
- public int getBlockIncrement() {
- return this.blockIncrement;
- }
-
- public int getBlockIncrement(int direction) {
- return this.blockIncrement;
- }
-
- public int getMaximum() {
- return this.getModel().getMaximum();
- }
-
- public Dimension getMaximumSize() {
- Dimension pref = ((JComponent)this).getPreferredSize();
- return this.getOrientation() == 1 ? new Dimension(pref.width, 32767) : new Dimension(32767, pref.height);
- }
-
- public int getMinimum() {
- return this.getModel().getMinimum();
- }
-
- public Dimension getMinimumSize() {
- Dimension pref = ((JComponent)this).getPreferredSize();
- return this.orientation == 1 ? new Dimension(pref.width, 5) : new Dimension(5, pref.height);
- }
-
- public BoundedRangeModel getModel() {
- return this.model;
- }
-
- public int getOrientation() {
- return this.orientation;
- }
-
- public ScrollBarUI getUI() {
- return (ScrollBarUI)super.ui;
- }
-
- public String getUIClassID() {
- return "ScrollBarUI";
- }
-
- public int getUnitIncrement() {
- return this.unitIncrement;
- }
-
- public int getUnitIncrement(int direction) {
- return this.unitIncrement;
- }
-
- public int getValue() {
- return this.getModel().getValue();
- }
-
- public boolean getValueIsAdjusting() {
- return this.getModel().getValueIsAdjusting();
- }
-
- public int getVisibleAmount() {
- return this.getModel().getExtent();
- }
-
- public void removeAdjustmentListener(AdjustmentListener l) {
- EventListenerList var10000 = super.listenerList;
- Class var10001 = class$java$awt$event$AdjustmentListener;
- if (var10001 == null) {
- try {
- var10001 = Class.forName("java.awt.event.AdjustmentListener");
- } catch (ClassNotFoundException var2) {
- throw new NoClassDefFoundError(((Throwable)var2).getMessage());
- }
-
- class$java$awt$event$AdjustmentListener = var10001;
- }
-
- var10000.remove(var10001, l);
- }
-
- public void setBlockIncrement(int blockIncrement) {
- int oldValue = this.blockIncrement;
- this.blockIncrement = blockIncrement;
- ((JComponent)this).firePropertyChange("blockIncrement", oldValue, blockIncrement);
- }
-
- public void setEnabled(boolean x) {
- super.setEnabled(x);
- Component[] children = ((Container)this).getComponents();
-
- for(int i = 0; i < children.length; ++i) {
- children[i].setEnabled(x);
- }
-
- }
-
- public void setMaximum(int maximum) {
- this.getModel().setMaximum(maximum);
- }
-
- public void setMinimum(int minimum) {
- this.getModel().setMinimum(minimum);
- }
-
- public void setModel(BoundedRangeModel newModel) {
- Integer oldValue = null;
- BoundedRangeModel oldModel = this.model;
- if (this.model != null) {
- this.model.removeChangeListener(this.fwdAdjustmentEvents);
- oldValue = new Integer(this.model.getValue());
- }
-
- this.model = newModel;
- if (this.model != null) {
- this.model.addChangeListener(this.fwdAdjustmentEvents);
- }
-
- ((JComponent)this).firePropertyChange("model", oldModel, this.model);
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleValue", oldValue, new Integer(this.model.getValue()));
- }
-
- }
-
- public void setOrientation(int orientation) {
- this.checkOrientation(orientation);
- this.orientation = orientation;
- ((JComponent)this).firePropertyChange("orientation", orientation, orientation);
- if (orientation != orientation && super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleState", orientation == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL, orientation == 1 ? AccessibleState.VERTICAL : AccessibleState.HORIZONTAL);
- }
-
- }
-
- public void setUnitIncrement(int unitIncrement) {
- int oldValue = this.unitIncrement;
- this.unitIncrement = unitIncrement;
- ((JComponent)this).firePropertyChange("unitIncrement", oldValue, unitIncrement);
- }
-
- public void setValue(int value) {
- BoundedRangeModel m = this.getModel();
- int oldValue = m.getValue();
- m.setValue(value);
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleValue", new Integer(oldValue), new Integer(m.getValue()));
- }
-
- }
-
- public void setValueIsAdjusting(boolean b) {
- BoundedRangeModel m = this.getModel();
- boolean oldValue = m.getValueIsAdjusting();
- m.setValueIsAdjusting(b);
- if (oldValue != b && super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleState", oldValue ? AccessibleState.BUSY : null, b ? AccessibleState.BUSY : null);
- }
-
- }
-
- public void setValues(int newValue, int newExtent, int newMin, int newMax) {
- BoundedRangeModel m = this.getModel();
- int oldValue = m.getValue();
- m.setRangeProperties(newValue, newExtent, newMin, newMax, m.getValueIsAdjusting());
- if (super.accessibleContext != null) {
- super.accessibleContext.firePropertyChange("AccessibleValue", new Integer(oldValue), new Integer(m.getValue()));
- }
-
- }
-
- public void setVisibleAmount(int extent) {
- this.getModel().setExtent(extent);
- }
-
- public void updateUI() {
- ((JComponent)this).setUI((ScrollBarUI)UIManager.getUI(this));
- }
- }
-